import helper from '../../helper';
import Vue from "vue";

export default {
    namespaced: true,
    state: {
        command: {
            window: false,
            history: [],
        },
    },
    mutations: {
        SET_COMMAND_WINDOW (state, data) {
            state.command.window = data;
            helper.setCache("command_window", data);
        },
        PUSH_COMMAND_HISTORY (state, data) {
            state.command.history.push(data);
            if (state.command.history.length > 100) {
                state.command.history.shift();
            }
            // helper.setCache("command_history", state.command.history.map(v=> {
            //     return v.serializeBinary();
            // }));
        }
    },
    actions: {
        ToggleCommandWindow({commit, state}) {
            commit('SET_COMMAND_WINDOW', !state.command.window);
        },
    },
    getters: {
        // header (state, getters, rootState) {
        //     return {
        //         Authorization: 'Bearer ' + rootState.manager.token,
        //     }
        // },
    }
};
